import {Component} from '@angular/core';
import {ICellRendererAngularComp} from '@ag-grid-community/angular';
import {ICellRendererParams} from '@ag-grid-community/core';

@Component({
  selector: 'apes-opt-button',
  template: `
    <div *ngIf="params; else elseNO">
      <i apes-icon apesType="plus" id="add">+</i>
      <i apes-icon apesType="delete" id="del">-</i>
    </div>
    <ng-template #elseNO>{{params.rowIndex + 1}}</ng-template>

   `,
  styles: []
})
export class RenderOptButtonComponent implements ICellRendererAngularComp {

    params: ICellRendererParams;
    constructor() { }
    refresh(params: any): boolean {
        return true;
    }
    agInit(params: ICellRendererParams): void {
        this.params = params;
    }
    _onDelete() {
        const currentData = this.params.data;
        this.params.api.updateRowData({ remove: [currentData] });
    }

}
